import type { RowType } from '#/views/onlineDesign/onlineConfig/config.data';

import { requestClient } from '#/api/request';

export namespace GenConfigTableApi {
  export type RowTypeFetchParams = RowType;
  export interface IdFetchParams {
    id: string;
  }
  export interface ListFetchParams {
    [key: string]: any;
  }
  export interface PageListFetchParams {
    [key: string]: any;
    pageNo: number;
    pageSize: number;
  }
}

/**
 * 分页列表查询
 */
export async function genConfigQueryPageListApi(
  params: GenConfigTableApi.PageListFetchParams,
) {
  return requestClient.get('/gen/genConfig/queryPageList', {
    params,
  });
}

/**
 * 列表查询
 */
export async function genConfigQueryListApi(
  params: GenConfigTableApi.ListFetchParams,
) {
  return requestClient.get('/gen/genConfig/queryList', { params });
}

/**
 * 通过ID查询
 * @param params
 */
export async function genConfigQueryByIdApi(
  params: GenConfigTableApi.IdFetchParams,
) {
  return requestClient.get('/gen/genConfig/queryById', { params });
}

/**
 * 新增
 */
export async function genConfigAddApi(
  params: GenConfigTableApi.RowTypeFetchParams,
) {
  return requestClient.post('/gen/genConfig/add', params);
}

/**
 * 编辑
 */
export async function genConfigEditApi(
  params: GenConfigTableApi.RowTypeFetchParams,
) {
  return requestClient.post('/gen/genConfig/edit', params);
}

/**
 * 删除
 * @param id 主键
 */
export async function genConfigDelApi(id) {
  return requestClient.delete<boolean>(`/gen/genConfig/delete/${id}`);
}

/**
 * 批量删除删除
 * @param ids 主键
 */
export async function genConfigDeleteBatchApi(ids) {
  return requestClient.delete<boolean>(
    `/gen/genConfig/deleteBatchByIds/${ids}`,
  );
}

/**
 * 查询一个
 */
export async function genConfigQueryOneApi() {
  return requestClient.get(`/gen/genConfig/queryOne`);
}

/**
 * 新增或编辑
 */
export async function genConfigAddOrEditApi(data) {
  return requestClient.post(`/gen/genConfig/addOrEdit`, data);
}
